package com.example.factory.ordinary;

import com.example.factory.Computer;

public class GDComputerFactory extends ComputerFactory2 {
    @Override
    public <T extends Computer> T createComputer2(Class<T> clz) {
        Computer computer = null;
        String className = clz.getName();
        try {
            computer = (Computer)Class.forName(className).newInstance();
        } catch (IllegalAccessException | InstantiationException | ClassNotFoundException e) {
            e.printStackTrace();
        }
        return clz.cast(computer);
    }
}
